package online.inote.common.core;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * <p>
 * Desc: 
 * </p>
 *
 * @author Sui
 * @created: 2017年12月3日 上午12:46:01
 * @version 1.0
 */
@Order(Integer.MAX_VALUE)
public class BaseController<T extends IdEntity> {
	
	@Autowired
	protected HttpServletRequest request;
	@Autowired
	protected HttpServletResponse response;
 
	protected Logger logger = LoggerFactory.getLogger(getClass());
	protected String JSP_PATH = getClass().getSimpleName().replace("Controller", "").toLowerCase() + "/";
	
	@Autowired
	protected BaseService<T> service;
	
	/**
	 * <p>
	 * Desc: 页面跳转
	 * </p>
	 *
	 * @author XQF SUI
	 * @created 2017年12月4日 下午1:02:17
	 * @param request
	 * @param path
	 * @return
	 */
	@RequestMapping(value = "jump/{path}", method = RequestMethod.GET)
	public String jump(HttpServletRequest request, @PathVariable(value = "path") String path) {
		return JSP_PATH + path;
	}
	
	public String view(String jsp) {
		return view(JSP_PATH, jsp);
	}
	
	public String view(String path, String jsp) {
		return path + jsp;
	}
}
